package cn.kgc.mvc.day02.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 课工场
 * @date 2024/7/19
 * @description    @RequestMapping使用
 *  @RequestMapping能接收什么类型的请求
 *  1.get
 *  2.post
 *  3.delete
 *  4.put
 *
 *  注解属性
 *  path: String[]  设置请求映射的路径   多路径映射
 *  method:  RequestMethod[]  设置请求的方式   RequestMethod.POST
 */
@Controller
@RequestMapping("user")
public class UserController {

    //
    //@RequestMapping("/user/add")
    @RequestMapping(path = {"add","insert"},method = {RequestMethod.POST,RequestMethod.GET} )
    public ModelAndView addUser(){
        System.out.println("----------add----------");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user");
        return modelAndView;
    }

    // /user/delete
    @RequestMapping(path={"delete","remove"},method = RequestMethod.DELETE)
    public ModelAndView deleteUser(){
        System.out.println("----------delete----------");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user");
        return modelAndView;
    }
}
